package com.github.jiangxch.rpc.transport.exchanger.jdk;

import com.github.jiangxch.rpc.transport.Channel;
import com.github.jiangxch.rpc.transport.Client;
import com.github.jiangxch.rpc.transport.exchanger.ExchangeChannel;
import com.github.jiangxch.rpc.transport.exchanger.ExchangeClient;

import java.io.IOException;
import java.net.InetSocketAddress;

/**
 * @author: jiangxch
 * @date: 2021/2/26 上午12:51
 */
public class JdkExchangeClient implements ExchangeClient {
    private Client client;
    private ExchangeChannel channel;
    
    public JdkExchangeClient(Client client) {
        this.client = client;
    }
    
    @Override
    public ExchangeChannel getChannel() {
        return channel;
    }
    
    @Override
    public InetSocketAddress getLocalSocketAddress() {
        return null;
    }
    
    @Override
    public void start() {
        client.start();
        channel = new JdkExchangeChannel(client.getChannel());
    }
    
    @Override
    public void close() {
        client.close();
    }
    
    @Override
    public boolean isClosed() {
        return false;
    }
    
    @Override
    public ExchangeChannel getExchangeChannel() {
        return channel;
    }
}
